package fun.codefarmer.pm.controller.management.basic;

import fun.codefarmer.pm.model.Position;
import fun.codefarmer.pm.model.RespBean;
import fun.codefarmer.pm.service.PositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ ClassName PositionController
 * @ Descriotion TODO
 * @ author  codeFarmer_z
 * @ 公众号：码农教程
 * @ Date 2022/4/18 17:29
 **/
@RestController
@RequestMapping("/system/basic/pos")
public class PositionController {
    @Autowired
    private PositionService positionService;

    /**
     * 查询
     * @return
     */
    @GetMapping("/")
    public List<Position> getAllPosition() {

        return positionService.getAllPosition();
    }

    /**
     * 新增
     * @param position
     * @return
     */
    @PostMapping("/")
    public RespBean addPosition(@RequestBody Position position) {
        return positionService.addPosition(position);
    }

    /**
     * 修改
     * @param position
     * @return
     */
    @PutMapping("/")
    public RespBean updatePosition(@RequestBody Position position) {
        return positionService.updatePosition(position);

    }

    /**
     * 单挑删除
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public RespBean deletePosition(@PathVariable Integer id) {
        return positionService.deletePosition(id);
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @DeleteMapping("/")
    public RespBean deletePositionByIds(Integer[] ids) {
        return positionService.deletePositionByIds(ids);
    }
}
